--构筑星夜
local gouzhuxingye = fk.CreateSkill {
    name = "mcdh_gouzhuxingye",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

gouzhuxingye:addEffect(fk.EventPhaseStart,{
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(self) and target == player and target.phase == Player.Start
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local num = #lib.getPublicCards(player)
        self.cost_data = {num}
        if num == 0 then
            return room:askForSkillInvoke(player, self.name, data,"#gouzhuxingye0")
        elseif num == 1 and player:isWounded() then
            return room:askForSkillInvoke(player, self.name, data,"#gouzhuxingye1")
        elseif num == 2 then
            return  room:askForSkillInvoke(player, self.name, data,"#gouzhuxingye2")
        elseif num == 3 then
            local targets = table.map(room.alive_players, Util.IdMapper)
            table.removeOne(targets,player.id)
            targets = room:askToChoosePlayers(player, {targets = targets,min_num=1,max_num=1,prompt= "#gouzhuxingye3",skill_name = self.name})
            if #targets ~= 0  then
                self.cost_data = {num,targets[1]}
                return true
            end

        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local num = self.cost_data[1]
        if num == 0 then
            player:drawCards(1,self.name)
        elseif num == 1 then
            room:recover{
                who = player,
                recoverBy = player,
                skillName =self.name,
                num = 1,
            }
        elseif num == 2 then
            player:drawCards(2,self.name)
        elseif num == 3 then
            lib.Damage({
                from = player,
                to = self.cost_data[2],
                damage = 1,
                damageType = fk.ThunderDamage,
                skillName = self.name,
            })
        end
    end
})

Fk:loadTranslationTable {
    ["mcdh_gouzhuxingye"] = "构筑星夜",
    [":mcdh_gouzhuxingye"] = "准备阶段，你可以执行第X项：0.摸一张牌；1.回复1点体力；2.摸两张牌；3.对一名其他角色造成1点雷电伤害（仪为你的明置牌数且至多为3）。",
    ["#gouzhuxingye0"] = "构筑星夜:摸一张牌",
    ["#gouzhuxingye1"] = "构筑星夜:回复1点体力",
    ["#gouzhuxingye2"] = "构筑星夜:摸两张牌",
    ["#gouzhuxingye3"] = "构筑星夜:对一名其他角色造成1点雷电伤害",
}

return gouzhuxingye